transform

old TransE-like models
git clone https://esimon.eu/repos/transform.git
Log | Files | Refs | README

affine hadamard.py (592B)


      1 #!/usr/bin/env python2
      2 
      3 from relations.base import *
      4 
      5 class Affine_hadamard(Base_relation):
      6     """ Affine hadamard class.
      7 
      8     This class has two parameters:
      9     A -- the multiplicative vectors
     10     B -- the additive vectors
     11     """
     12     def __init__(self, rng, number, dimension, tag):
     13         """ Initialise the parameter. """
     14         parameters = [ ('A', (dimension,)), ('B', (dimension,)) ]
     15         super(Affine_hadamard, self).__init__(rng, number, parameters, tag)
     16 
     17     def apply(self, inputs, a, b):
     18         """ Apply the given relations to a given input. """
     19         return a*inputs+b